home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / tmhst24a.zip / TMHOST24.SCR < prev    next >
Text File  |  1993-10-21  |  70KB  |  2,257 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;; HOST.SCR by Tsung Hu, 21 May, 1990
  3. ;; Modified by Richard Bailey Dec 1990
  4. ;; Renamed TMHOST2, see comments throughout file explaining changes.
  5. ;; Modified by Bob Wiatr Aug. 1992 to use with Telemate 3.02 & 3.10                    
  6. ;; Renamed TMHOST21.
  7. ;; Modified by Bob Wiatr April 18, 1993 to use with Telemate 4.0
  8. ;; Renamed TMHOST22
  9. ;; Modified by Bob Wiatr Sept. 1993 to use with Telemate 4.12
  10. ;; Renamed TMHOST24A
  11.  
  12. #include "SCREENIO.SCR"
  13.  
  14. ;
  15. ; constants
  16. ;          
  17. EchoToLocal = 1                    ; variables set to TRUE
  18. EchoToRemote = 1                   ; for SCREENIO routines
  19. TRUE = 1
  20. FALSE = 0
  21. FOREVER = TRUE
  22. TMLOG = "\TMDIR\TM.USE"
  23. FILEDIR = "\HOST.DIR"           ; temp. file for F)ile command
  24. MENUCOMMAND = " Minutes left. Enter Command  "
  25. XPERTCOMMAND = " Minutes left. Enter Command (? for help)  "
  26. TMHOST = "***TMHOST BBS VER. 2.4 ***"
  27.  
  28. ;
  29. ; global variables
  30. ;
  31. integer access,addmsg,areanum,exist,mail,mins,msgmail,msgread,msgs,ontime
  32. integer reply,savedmsg,timeleft,userlevel,xpert
  33. integer NEWUSERLEVEL,NUSERLEVEL,SYSOPLEVEL,DETECTBAUD,INITIALBAUD,YELLTIME
  34. integer YELLSOUND,LOCAL,COUNT,CLOSESYSTEM,FILELIST
  35.  
  36. string area,ch,filename,logontime,name,now,password,subject,today
  37. string GENBKCOL,HEADERBKCOL,GENTEXTCOL,HEADERTEXTCOL,HILITECOL,MSGBASE
  38. string totalmsgs,username,wdate
  39. string SPECIALTEXTCOL,LOCALBOXCOL,LOCALCOL,TMDIR,HOSTDIR,DOWNLOADDIR
  40. string MSBASE0,MSBASE1,MSBASE2,MSBASE3,MSBASE4,MSBASE5,MSBASE6,MSBASE7
  41. string MSBASE8,MSBASE9  
  42. string area0,area1,area2,area3,area4,area5,area6,area7,area8,area9
  43.  
  44. Procedure CheckDirectory string dir
  45.    integer l,pos
  46.    string ch,firstdir
  47.    strpos dir,";",pos
  48.    if pos>0
  49.       substr dir,1,pos-1,firstdir
  50.       dir = firstdir
  51.    endif
  52.    length dir,l
  53.    if l>0
  54.       substr dir,l,1,ch
  55.       if ch<>"\" and ch<>":"
  56.          concat dir,"\"
  57.       endif
  58.    endif
  59. Endproc
  60.  
  61.  
  62. Procedure HostConfig               ; read the configuration file
  63.    string s,ch                     ; TMHCFG.HST from the current directory
  64.    open "TMHCFG.HST"
  65.      if success
  66.        read s                                                  
  67.        atoi s,NEWUSERLEVEL         ; new user level
  68.        read s
  69.        atoi s,NUSERLEVEL           ; normal user level
  70.        read s
  71.        atoi s,SYSOPLEVEL           ; sysop level
  72.        read s
  73.        atoi s,DETECTBAUD           ; detect baud rate
  74.        read s
  75.        atoi s,INITIALBAUD          ; initial baud rate
  76.        read s
  77.        atoi s,YELLTIME             ; yell time
  78.        read s
  79.        atoi s,YELLSOUND            ; yell sound
  80.        read TMDIR
  81.        read HOSTDIR                ; directory containing H*.HST
  82.        read DOWNLOADDIR            ; download directory
  83.        read s                      ; (upload goes to TM dl DIR)
  84.        atoi s,CLOSESYSTEM          ; Read if system is closed
  85.        read s
  86.        atoi s,FILELIST
  87.        read GENBKCOL               ; general background colour
  88.        read GENTEXTCOL             ; general text colour
  89.        read HILITECOL              ; hilite colour 
  90.        read HEADERBKCOL            ; header background colour
  91.        read HEADERTEXTCOL          ; header text colour 
  92.        read SPECIALTEXTCOL         ; e.g. questionnaire text colour
  93.        read LOCALBOXCOL            ; local box colour e.g. starting Host mode
  94.        read LOCALCOL               ; local text colour
  95.        read s
  96.        atoi s,COUNT                ; number of message areas
  97.        read area0                  ; message areas 
  98.        read MSBASE0                ; and files
  99.        read area1
  100.        read MSBASE1
  101.        read area2 
  102.        read MSBASE2
  103.        read area3 
  104.        read MSBASE3
  105.        read area4 
  106.        read MSBASE4
  107.        read area5
  108.        read MSBASE5 
  109.        read area6 
  110.        read MSBASE6
  111.        read area7
  112.        read MSBASE7
  113.        read area8 
  114.        read MSBASE8 
  115.        read area9 
  116.        read MSBASE9
  117.        read s
  118.        atoi s,ANSILOCAL
  119.        close
  120.                     ; CheckDirectory HOSTDIR
  121.                     ; CheckDirectory DOWNLOADDIR
  122.        set alarmtime,YELLTIME      ; setup yell alarm
  123.        set alarmsound,YELLSOUND
  124.      else
  125.        print "Cannot open TMHCFG.HST in the current directory"
  126.        print
  127.        print "Do you want to setup host mode (y/n)? ",
  128.        repeat
  129.          inputch ch
  130.        until success
  131.          if ch="y"
  132.            print ch
  133.            script "TMHCFG"         ; chain to TMHCFG.SCR
  134.          else
  135.            print "n"               ; abort host mode
  136.            print "Host mode aborted"
  137.            stop
  138.          endif
  139.      endif
  140. Endproc                                         
  141.  
  142. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  143. ;; Function to calculate time difference in minutes between time1 and time2
  144. ;; for calculation of time left for user, ties in <timeleft> and <ontime>
  145. ;; Modification of Difftime function from Toolbox3.scr
  146. ;;
  147.  
  148. Procedure CalcTime string time1,time2,integer minutes
  149.   integer h1,m1,h2,m2     ; <time1> and <time2> in "HH:MM:SS" format
  150.   string hh,mm
  151.   substr time1,1,2,hh              ; get hour part
  152.   substr time1,4,2,mm              ; get minute part
  153.   atoi hh,h1                       ; convert to integer
  154.   atoi mm,m1
  155.   substr time2,1,2,hh              ; get hour,minute and second from <time2>
  156.   substr time2,4,2,mm
  157.   atoi hh,h2
  158.   atoi mm,m2
  159.   if h2<h1                         ; <time2> pass mid-night
  160.     h2 = h2 + 24
  161.   endif
  162.   minutes = (h2-h1)*60 + (m2-m1)
  163. EndProc
  164.  
  165. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  166. ;; New Procedure FULLDATE 
  167. ;; Setup a date string
  168. ;; When full is TRUE, date format e.g. 'Friday December 14, 1990'
  169. ;; When full is FALSE, date format DD-MM-YY e.g. '14-12-90'
  170. ;; Telemate version of date is MM-DD-YY e.g '12-14-90'
  171. ;;
  172.  
  173. Procedure FullDate string strdate,integer full
  174.   string datestr,mm,dd,yy,day,month,year,century
  175.   integer y1,d1,daynum,totaldays,numdays
  176.   date datestr                     ; get date string
  177.   substr datestr,1,2,mm            ; month
  178.   substr datestr,4,2,dd            ; date
  179.   substr datestr,7,2,yy            ; year
  180.   atoi yy,y1
  181.   atoi dd,d1
  182.   if not full
  183.     concat dd,"-"                  ; DD-MM-YY
  184.     concat dd,mm
  185.     concat dd,"-"
  186.     concat dd,yy
  187.     strdate = dd   
  188.   else
  189.     switch mm
  190.       case " 1":
  191.         month = " January "
  192.         numdays = 0
  193.       case " 2":
  194.         month = " February "
  195.         numdays = 31
  196.       case " 3":
  197.         month = " March "
  198.         numdays = 59
  199.       case " 4":
  200.         month = " April "
  201.         numdays = 90
  202.       case " 5":
  203.         month = " May "
  204.         numdays = 120
  205.       case " 6":
  206.         month = " June "
  207.         numdays = 151
  208.       case " 7": 
  209.         month = " July "
  210.         numdays = 181
  211.       case " 8":
  212.         month = " August "
  213.         numdays = 212
  214.       case " 9":
  215.         month = " September "
  216.         numdays = 243
  217.       case "10":
  218.         month = " October "
  219.         numdays = 273
  220.       case "11":
  221.         month = " November "
  222.         numdays = 304
  223.       case "12":
  224.         month = " December "
  225.         numdays = 334
  226.     endswitch
  227.     century = " 19"
  228.     if y1 > 99
  229.       century = " 20"
  230.     endif
  231.     totaldays = (y1-80)*365+1+(y1-80)/4+numdays+d1 
  232.     daynum = totaldays-((totaldays/7)*7)
  233.     switch daynum
  234.       case 0: day = " Monday"
  235.       case 1: day = " Tuesday"
  236.       case 2: day = " Wednesday"
  237.       case 3: day = " Thursday"
  238.       case 4: day = " Friday"
  239.       case 5: day = " Saturday"
  240.       case 6: day = " Sunday"
  241.     endswitch              
  242.     concat day," "
  243.     concat day,month
  244.     concat day,dd
  245.     concat day,","
  246.     concat day,century
  247.     concat day,yy
  248.     strdate = day                  ; DAY MONTH DD, CENTURY YY
  249.   endif                  
  250. Endproc    
  251.  
  252. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  253. ;; New graphic delay routine used in message saving etc.
  254. ;; 
  255.  
  256. Procedure Save
  257.   integer i
  258.   i = 0
  259.   while i < 15
  260.     Echo "."
  261.     delay 3
  262.     i = i+1
  263.   endwhile
  264. Endproc
  265.  
  266. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  267. ;; New procedure LOCALVIEW 
  268. ;; who's online
  269. ;;
  270.  
  271. Procedure LocalView                ; shows user on line locally
  272.   EchoHilite
  273.   EchoColor LOCALBOXCOL
  274.   at 0,0
  275.   print "╔════════════════════════════╡                    ╞════════════════════════════╗"
  276.   print "║ ONLINE:                                                     DATE:            ║"
  277.   print "╚══════════════════════════════════════════════════════════════════════════════╝^M^J"
  278.   EchoColor LOCALCOL
  279.   at 31,0
  280.   print TMHOST
  281.   at 68,1
  282.   print today
  283.   at 10,1
  284.   print username                   ; user online
  285.   EchoNormal
  286. Endproc
  287.  
  288. Procedure HostBegin 
  289.    set zautodownload,off
  290.    set zrecovery,off 
  291.    set usagelog,on
  292.    set baud,INITIALBAUD
  293.    clear key                       ; clear keyboard buffer
  294.    clear com                       ; clear com buffer
  295.    clear text                      ; clear screen
  296.    print
  297.    print
  298.    print "Initializing modem"
  299.    put "ATH0^M~","^)","~ATQ0E0X4^M~",        ; send modem answer string
  300.    delay 5  
  301.    clear text
  302.    EchoColor LOCALBOXCOL
  303.    print "^M^J^M^J^M^J^M^J"
  304.    print "            ┌────────────────────┐ "
  305.    print "        ╒═══╡          Host 2.4  ╞════════════════════╕ "
  306.    print "        │   └────────────────────┘                    │ "
  307.    print "        │           : Waiting for call.....           │ "
  308.    print "        │ ─────────────────────────────────────────── │ "
  309.    print "        │           : Press [   ] to exit Host Mode   │ "
  310.    print "        │             ' ' for configuration           │ "
  311.    print "        │             ' ' for local mode              │ "
  312.    print "        │             ' ' for Offhook local           │ "
  313.    print "        │             [     ] to terminate user       │ "
  314.    print "        ╘═════════════════════════════════════════════╛ "
  315.    print
  316.    EchoColor LOCALCOL
  317.    at 14,6
  318.    print "TELEMATE"
  319.    at 14,8
  320.    print "STATUS"
  321.    at 13,10
  322.    print "OPTIONS"
  323.    at 29,10          ;at 29,10
  324.    print "ESC"
  325.    at 23,11
  326.    print "C"
  327.    at 23,12
  328.    print "L"
  329.    at 23,13
  330.    print "O"
  331.    at 23,14
  332.    print "Alt-H"
  333.    at 44,8
  334.    clear key                       ; clear keyboard buffer
  335.    clear com                       ; clear com buffer     
  336.    
  337.                 ; Do calculations before answering call
  338.  
  339.    FullDate today,FALSE            ; string right way round, not full date
  340.    FullDate wdate,TRUE             ; full date string for welcome
  341.    MSGBASE = MSBASE0               ; message to sysop base
  342.    area = area0
  343.    areanum = 1                     ; message area number (command line)
  344.    access = TRUE 
  345.    usage "Switched to Host mode"
  346. Endproc
  347.  
  348. Procedure HostEnd
  349.   set zautodownload,on
  350.   set zrecovery,on
  351.   clear key                        ; clear keyboard buffer
  352.   clear com                        ; clear com buffer
  353.   clear text
  354.   print
  355.   print "Ending host mode"
  356.   put "^(","~",                    ; send modem init string
  357.   print
  358.   chdir HOSTDIR                    ; change to Host dir
  359.   delete FILEDIR                   ; delete temp file
  360.   chdir TMDIR                      ; change back to Telemate dir
  361.   usage "Terminating Host mode"
  362.   set usagelog,off
  363.   stop
  364. Endproc
  365.  
  366. Procedure Disconnect               ; end session
  367.   delay 10
  368.   if not LOCAL                     ; if remote
  369.     hangup
  370.   endif
  371.   set connection,modem
  372.   LOCAL = FALSE
  373. Endproc
  374.  
  375. Procedure InputChar string ch      ; input and display locally
  376.   repeat                     
  377.   if not LOCAL                   ; get remote characters
  378.      getch ch
  379.     endif
  380.       if LOCAL or not success
  381.         inputch ch
  382.           if success
  383.             if ch = "^["
  384.               HostEnd
  385.             endif
  386.             print ch,
  387.           endif
  388.       endif
  389.    until success or not connected
  390.   Endproc
  391.  
  392. Procedure InputEcho string ch      ; input and echo to remote
  393.   InputChar ch
  394.   if not LOCAL
  395.     put ch,
  396.   endif
  397.   if ch = "^M"                     ; add line feed
  398.     Echo "^J"
  399.   endif
  400. Endproc
  401.  
  402. Procedure DotEcho string ch        ; input and echo "." to remote
  403.   InputChar ch
  404.   if not LOCAL
  405.     if ch="^H" or ch="^M"
  406.       put ch,
  407.     else
  408.       put ".",                     ; echo with "."
  409.     endif
  410.   endif
  411.   if ch = "^M"                     ; add line feed
  412.       Echo "^J"
  413.   endif
  414. Endproc
  415.  
  416. Procedure InputString string str   ; input a string
  417.   string ch
  418.   str = ""
  419.   repeat
  420.     InputEcho ch
  421.     if ch <> "^M"                  ; if return
  422.       if ch = "^H"                 ; if backspace
  423.         if str = ""                ; if string empty
  424.           Echo " "
  425.         else
  426.           Echo " ^H"
  427.         endif
  428.       endif
  429.       concat str,ch
  430.     endif
  431.   until ch = "^M" or not connected
  432.   if str="" or not connected
  433.     success = FALSE
  434.   else
  435.     success = TRUE
  436.   endif
  437. Endproc
  438.  
  439. Procedure InputFilename string filename,dir
  440.   string fname       
  441.   integer pos
  442.   InputString fname                ; input a filename
  443.   repeat
  444.     strpos fname,":",pos           ; strip drive part
  445.       if pos>0                     ; only view file
  446.          strdel fname,1,pos        ; in download dir
  447.       endif
  448.   until pos=0 or not connected
  449.   repeat
  450.     strpos fname,"\",pos           ; strip directory part
  451.       if pos>0
  452.          strdel fname,1,pos
  453.       endif
  454.   until pos=0 or not connected
  455.     if fname="" or not connected
  456.       success = FALSE
  457.       filename = ""
  458.     else
  459.       success = TRUE
  460.       filename = dir
  461.       concat filename,"\"          ; concat <dir>
  462.       strpos filename,"\\",pos
  463.         if pos>0
  464.           strdel filename,pos,1    ; avoid root directory
  465.         endif
  466.       concat filename,fname
  467.     endif
  468. Endproc  
  469.  
  470. Procedure Pause                    ; request a key
  471.   string ch
  472.   Echo "Press [ENTER] to continue "
  473.   InputEcho ch
  474.   Echo "^M^J"
  475.   if ch<>"^M"
  476.     Echo "^M^J"
  477.   endif
  478. Endproc
  479.  
  480. Procedure InputPassword string password
  481.   password = ""
  482.   repeat                           ; input password
  483.     DotEcho ch
  484.       if ch <> "^M"
  485.         if ch = "^H"
  486.           if password = ""
  487.             Echo " "
  488.           else
  489.             Echo " ^H"
  490.           endif
  491.         endif
  492.         concat password,ch
  493.       endif
  494.   until ch = "^M" or not connected
  495.     if password="" or not connected
  496.       success = FALSE
  497.     else
  498.       success = TRUE
  499.     endif
  500. Endproc                                         
  501.  
  502. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  503. ;; Added choice of y/n to [more] in Typefile procedure
  504. ;;
  505.  
  506. Procedure TypeFile string filename,integer more
  507.   string ch                        ; display a file
  508.   integer i
  509.   i = 0
  510.   open filename
  511.   if not success
  512.     Echo "File not found!^M^J"
  513.   else
  514.     while success
  515.       inputch ch
  516.       if success and ch = "^C"     ; operator break
  517.         clear com
  518.         Echo "^M^J"
  519.         exit
  520.       endif
  521.       if not LOCAL
  522.         getch ch
  523.           if success and ch = "^C" ; caller break
  524.             clear com
  525.             Echo "^M^J"
  526.             exit
  527.           endif
  528.       endif
  529.       read s                       ; display a line
  530.       Echo s
  531.       Echo "^M^J"  
  532.       i = i+1
  533.       if i = 22 and more           ; pause if <more> is TRUE
  534.         i = 0
  535.         Echo " More [y/N] "
  536.         InputChar ch
  537.         if ch = "^M" or ch = "N"   ; if no, stop
  538.           clear com
  539.           Echo "^M^J"
  540.           exit
  541.         endif
  542.         Echo "^M                    ^M"
  543.       endif  
  544.     endwhile
  545.     close
  546.     if more
  547.       Pause
  548.     endif
  549.   endif
  550. Endproc            
  551.  
  552. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  553. ;; New Procedure READMAIL
  554. ;; MSGBASE = message area.
  555. ;; At logon a choice is provided to read personal mail from 
  556. ;; messages areas. Checks the 'To    : name' field of message header
  557. ;; and displays appropriate message. An 'R' is placed in the 
  558. ;; 'To   :' string --> 'To  R :' which serves 2 purposes:
  559. ;; 1) The same messages are not displayed at future logons,
  560. ;;    string now changed.
  561. ;; 2) The Sysop can edit out the message once it has been rec'd.
  562. ;;           
  563.  
  564. Procedure ReadMail string MSGBASE
  565.   string toname,s
  566.   integer found,pos,filepos,len,i,more
  567.   savedmsg = FALSE 
  568.   chdir HOSTDIR
  569.   open MSGBASE 
  570.   if not success
  571.     Echo "^M^JSystem Error - no messages available at this time!^M^J"
  572.     print "SYSOP: Cannot find ",MSGBASE," file"
  573.     alarm "SYSOP: Cannot find MESSAGE file, disk full ?"
  574.     return
  575.   endif   
  576.   repeat
  577.   found = FALSE
  578.   read s
  579.   while success and not found      ; locate message 'To:' field
  580.     strpos s,"To     :",pos         
  581.     if pos>0 
  582.       substr s,pos+9,30,toname
  583.       if toname=username           ; username?
  584.         length toname,len          ; length of name
  585.         found = TRUE
  586.         msgread = TRUE       
  587.         tell filepos               ; save file position 
  588.         seek filepos-len-8         ; back to middle of 'To   :' string 
  589.         write "R",                 ; 'R'means message received
  590.       endif                        ; won't be shown on future  
  591.     endif                          ; logons - can be deleted by 
  592.     if not found                   ; Sysop
  593.       read s 
  594.     endif
  595.   endwhile
  596.   if found                       
  597.     i = 0  
  598.     mail = mail+1
  599.     seek filepos-90                ; start of message
  600.     EchoNormal
  601.     Echo "^M^J"
  602.     repeat
  603.       read s                       ; display message
  604.       Echo s
  605.       Echo "^M^J" 
  606.       more = TRUE
  607.       i = i+1
  608.       if i = 22 and more              
  609.         i = 0
  610.         Echo " More [y/N] "        ; pause if long message
  611.         InputChar ch
  612.         if ch = "^C" or ch = "N"
  613.           clear com
  614.           Echo "^M^J"
  615.           exit
  616.         endif
  617.         Echo "^M                    ^M"
  618.       endif  
  619.     until s = " End of Message"   ; end of message
  620.     EchoHilite
  621.     EchoColor SPECIALTEXTCOL
  622.     Echo "Continue [Y/n] "         ; read more mail?
  623.     InputEcho ch
  624.     if ch = "N"
  625.       success = FALSE
  626.     endif
  627.   endif
  628.   until not success
  629.   close
  630.   chdir TMDIR    
  631.   msgmail = TRUE
  632. Endproc  
  633.  
  634. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  635. ;; Changed record length in Checkuser routine, added expert menu
  636. ;; variable TRUE or FALSE for logon 'Menu Mode' and how many 
  637. ;; messages left for user.
  638. ;; Padded with spaces to provide for different password size
  639. ;; when changed by 'Change Password routine'.
  640. ;;
  641.  
  642. Procedure CheckUser string username,password,integer level,xpert,msgs,valid
  643.   integer found,pos1,pos2
  644.   string record,recordname,pass,lev,x,m
  645.   strpos username,";",pos1     ; record format: "first last;password#level
  646.   strpos username,"#",pos2     ;                  %xpert&msgs"
  647.     if pos1>0 or pos2>0 
  648.       valid = FALSE
  649.       return
  650.     endif
  651.   strpos password,";",pos1         ; check password for invalid character
  652.   strpos password,"#",pos2         ;  prevent "#2" etc
  653.     if pos1>0 or pos2>0
  654.       valid = FALSE
  655.       return
  656.     endif
  657.   chdir HOSTDIR
  658.   open "PASSWORD.HST"              ; passwords in PASSWORD.HST
  659.   if not success
  660.      if not success
  661.          create "PASSWORD.HST"
  662.      endif   
  663.        if not success
  664.          Echo "System error, please call again later^M^J"
  665.          print "SYSOP: Cannot create PASSWORD.HST"
  666.          Disconnect
  667.          alarm "SYSOP: Cannot create PASSWORD.HST, disk full ?"
  668.          return
  669.        endif 
  670.   endif    
  671.   found = FALSE
  672.   read record
  673.   while success and not found
  674.     strpos record,";",pos1         ; get fields from the record
  675.     strpos record,"#",pos2
  676.     if pos1>0 and pos2>0
  677.       substr record,1,pos1-1,recordname
  678.       substr record,pos1+1,pos2-pos1-1,pass
  679.       if recordname=username
  680.         found = TRUE
  681.           if pass=password
  682.             valid = TRUE
  683.             substr record,pos2+1,1,lev
  684.             atoi lev,level             ; get userlevel
  685.             substr record,pos2+3,1,x
  686.             atoi x,xpert               ; get menu mode
  687.             substr record,pos2+5,3,m
  688.             atoi m,msgs                ; how many personal messages
  689.           else
  690.             valid = FALSE
  691.           endif
  692.       endif
  693.     endif
  694.     if not found
  695.       read record
  696.     endif
  697.   endwhile
  698.   if not found                     ; new users
  699.     if CLOSESYSTEM
  700.         print "This is a closed board"  
  701.         Disconnect
  702.         return
  703.     else
  704.        open "PASSWORD.HST"            ; else add new user
  705.        seek -1
  706.         write username,";",password,"#",NEWUSERLEVEL,"%",0,"&",0,"                                                                      " 
  707.  
  708.           ; user information record with extra spaces for 'password 
  709.           ; change' length and any further addition of variables 
  710.           ; at a later date. Field length - varies with length of
  711.           ; name or password, however 70 spaces at end
  712.  
  713.        usage "Newuser added to password file"
  714.        level = 1 
  715.        xpert = FALSE
  716.        valid = TRUE
  717.     endif
  718.   endif   
  719.   close
  720.   chdir TMDIR
  721. Endproc                             
  722.  
  723. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  724. ;; New Procedure WRITENEWRECORD
  725. ;; Routine to update PASSWORD.HST file for change of password, menu
  726. ;; mode status or 'add to' or 'take away' number of personal messages.
  727. ;;
  728. ;; ReadMail procedure adds number of messages read at logon,
  729. ;; Entermsg procedure sets addmsg to 1 which is added to msgs.
  730. ;;
  731. ;; rname =  'username' or 'name' for No. of personal messages 
  732. ;; Reads original record and then updates
  733. ;;
  734.  
  735. Procedure WriteNewRecord  string rname
  736.   integer found,filepos,len,pos1,pos2
  737.   string recordname,record,pass,lev,x,m                
  738.   chdir HOSTDIR
  739.   open "PASSWORD.HST"              
  740.   if not success
  741.     Echo "System error, please call again later^M^J"
  742.     print "SYSOP: Cannot locate PASSWORD.HST"
  743.     Disconnect
  744.     alarm "SYSOP: Cannot locate PASSWORD.HST, disk full ?"
  745.     return
  746.   endif
  747.   filepos = 0         
  748.   found = FALSE            
  749.   read record              
  750.   while success and not found      ; locate record
  751.     strpos record,";",pos1
  752.     strpos record,"#",pos2
  753.     if pos1>0 and pos2>0
  754.       substr record,1,pos1-1,recordname  ; locate name
  755.       substr record,pos1+1,pos2-pos1-1,pass
  756.       if recordname=rname               ; is it correct
  757.         found = TRUE                       
  758.         substr record,pos2+1,1,lev      ; get level etc
  759.         substr record,pos2+3,1,x
  760.         substr record,pos2+5,3,m
  761.         atoi m,msgs
  762.         if msgmail
  763.           msgs = msgs - mail
  764.         endif
  765.         if savedmsg  
  766.           msgs = msgs + addmsg
  767.         endif
  768.       endif
  769.     endif 
  770.     length record,len              ; find length of record
  771.     filepos = filepos+len+2        ; add 2 for carriage return
  772.     if not found                   ; and linefeed bytes
  773.       read record
  774.     endif
  775.   endwhile
  776.   if found             
  777.     seek filepos-len-2             ; write over record
  778.     if rname = username            ; logged on user? if another user,
  779.                                    ; keep record update messages
  780.       write rname,";",password,"#",userlevel,"%",xpert,"&",msgs,"                                                  ",
  781.     else
  782.       write rname,";",pass,"#",lev,"%",x,"&",msgs,"                                                   ",
  783.     endif                                            ;
  784.          ; it is important when editing password file 
  785.          ; that field length is kept 'as is'.
  786.          ; spaces are needed in case 'password' is shorter
  787.          ; than original when change of password made.
  788.  
  789.   endif
  790.   close      
  791.   chdir TMDIR    
  792.   msgmail = FALSE
  793. Endproc
  794.  
  795. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  796. ;; New Procedure ENTERMSG
  797. ;; addmsg variable increments number of personal messages 
  798. ;; being left to another user. Number of messages for user is checked
  799. ;; in PASSWORD.HST and updated by WriteNewRecord routine
  800. ;; Messages saved in a a message base file depends on MSBASE variable.
  801. ;; Updates number of messages at head of file.
  802. ;; End of message marker used to detect end of message when reading.
  803. ;; If replying to messages, To 'Name' entry is automatic,
  804. ;; optional same 'Subject'
  805. ;; Save and Kill message commands.
  806. ;; 
  807.  
  808. Procedure EnterMsg                     ; leave message
  809.   integer x,y,num,delpos,filepos       
  810.   integer msgnumber
  811.   string msg,str                       
  812.   filepos = 0                          
  813.   savedmsg = FALSE                     
  814.   clear text
  815.   clear com 
  816.   EchoClearScreen                  ; see screenio.scr
  817.   Echo "^M^J"
  818.   chdir HOSTDIR
  819.   open MSGBASE                     ; open message file
  820.   if not success                   ; e.g Message to Sysop
  821.       create MSGBASE
  822.   endif
  823.   if not success
  824.         Echo "System error, please call again later^M^J"
  825.         print "SYSOP: Cannot create ",MSGBASE," file"
  826.         Disconnect
  827.         alarm "SYSOP: Cannot create MESSAGE file, disk full ?"
  828.         return
  829.       endif  
  830.     read totalmsgs                 ; read number of existing messages
  831.     atoi totalmsgs,num             ; in message file, convert to an
  832.     msgnumber = num                ; integer to write new message No. 
  833.     EchoHilite
  834.     EchoBkColor HEADERBKCOL
  835.     EchoColor HEADERTEXTCOL 
  836.     Echo area                      ; display message base
  837.     Echo "......Press <Ctrl-Z> to End"
  838.     EchoBkColor GENBKCOL
  839.     Echo "^M^JFrom: "
  840.     Echo username
  841.     if MSGBASE = MSBASE0           ; if message to sysop
  842.       name = "Sysop"               ; put To Sysop
  843.       Echo "^M^J"
  844.     else
  845.       str = ""
  846.       Echo "^M^JTo: " 
  847.       EchoNormal 
  848.       if name = ""                 ; enter name of person to
  849.         InputString name           ; send message
  850.       else 
  851.        Echo name
  852.        Echo "^M^J"
  853.       endif
  854.       EchoHilite
  855.       EchoColor HEADERTEXTCOL
  856.     endif
  857.     if subject = ""                ; no subject?
  858.       Echo "Subject: (30 characters max.) " 
  859.       EchoNormal
  860.       InputString subject 
  861.     else  
  862.       Echo "Subject - Press [ENTER] for same or (S) for new subject: "
  863.       EchoNormal                   ; previous subject or new one?
  864.       InputEcho ch 
  865.       if ch = "^M" 
  866.         EchoHilite
  867.         EchoColor HEADERTEXTCOL
  868.         Echo "Subject: "       
  869.         EchoNormal
  870.         Echo subject               ; old subject
  871.       else
  872.         Echo "^M^J"
  873.         EchoHilite
  874.         EchoColor HEADERTEXTCOL
  875.         Echo "Subject: (30 characters max.) "
  876.         EchoNormal
  877.         InputString subject        ; new subject
  878.       endif
  879.       Echo "^M^J"
  880.     endif
  881.     msgnumber = msgnumber + 1      ; next message
  882.     seek filepos                   ; go to head of file
  883.     write msgnumber,"   ",         ; update number of messages
  884.     seek -1                        ; go to end of file 
  885.     tell delpos                    ; save file pointer for K)ill msg
  886.     write "^M^J                                   <-------->                                     " 
  887.     write " Msg#:",msgnumber 
  888.     write " From   : ",username
  889.     write " To     : ",name 
  890.     write " Date   : ",today,"  Time: ",now,"  Subject: ",subject  
  891.     write                          ; write header to file
  892.     tell filepos                   ; save file pointer to 
  893.     repeat                         ; control layout of message
  894.       InputEcho msg                ; get character
  895.       wherex x
  896.       if msg = " " and x>70
  897.         Echo "^M^J" 
  898.         msg = "^M^J "              ; space needed in message for
  899.         filepos = filepos+2        ; placement of linefeed character
  900.       else                         ; in file
  901.         if msg = "^H"              ; if backspace character, go back
  902.           filepos = filepos-1      ; 1 byte and write space
  903.           seek filepos
  904.           msg = " "
  905.         else
  906.           seek filepos             ; else go back and write character
  907.           filepos = filepos+1
  908.         endif
  909.         if msg = "^M"              ; if carriage return
  910.           msg = "^M^J"             ; linefeed in file
  911.           filepos = filepos+1
  912.         endif
  913.       endif
  914.       write msg,
  915.     until msg = "^Z"               ; end message
  916.     seek filepos-1                 ; write over end of file character
  917.     write "^M^J^M^J                                                  " 
  918.                                    ; record area for reply numbers
  919.     write " End of Message"       ; marker for read message routine
  920.     EchoHilite
  921.     EchoColor HEADERTEXTCOL
  922.     repeat     
  923.       Echo "^M^J^M^J S)ave or K)ill Message? "
  924.       InputEcho ch
  925.       if ch = "K"                  ; write over message
  926.         clear com
  927.         num = 0
  928.         seek delpos
  929.         read str
  930.         while success 
  931.           num = num+1
  932.           read str
  933.         endwhile
  934.         seek delpos                ; file position to delete from
  935.         write "^M^J"
  936.         while num>0
  937.         write "............................................................."
  938.           num = num-1              ; file can be edited later
  939.         endwhile
  940.         msgnumber = msgnumber-1    ; reduce message number
  941.         seek 0
  942.         write msgnumber,"   ",     ; spaces required in case of 10 -> 9 etc
  943.         Echo "^M^JMessage Deleted "
  944.         Save
  945.       elseif ch = "S"
  946.         clear com 
  947.         Echo "^M^JMessage Saved "
  948.         Save                 
  949.         If MSGBASE <> MSBASE0      ; if not Message to Sysop
  950.           addmsg = addmsg + 1               
  951.           savedmsg = TRUE          ; variables for WriteNewRecord
  952.         endif
  953.       endif
  954.     until ch = "S" or ch = "K"  
  955.     close 
  956.     chdir TMDIR
  957. Endproc
  958.  
  959. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  960. ;; New Procedure READMSG
  961. ;; S)can message headers, V)iew a selected message or press 
  962. ;; [ENTER] for next message, also can R)eply to message or Q)uit.
  963. ;; Total number of messages in selected message base displayed.
  964. ;; Keep 'Name' and 'Subject' for R)eply.
  965. ;; Number of replies to message shown as 'See Msg: #1, #2, #3 etc'.
  966. ;;
  967.  
  968. Procedure ReadMsg                  ; read messages
  969.   integer num,total,found,len,filepos,n,i,more,pos
  970.   string line1,line2,line3,line4,s,selnum,nextmsg
  971.  
  972.   Procedure ShowMsg                ; show message, used by V)iew
  973.     read s                         ; and [ENTER] for next message
  974.     while success and not found
  975.       strpos s,"Msg#:",pos         ; find message No.
  976.       if pos>0
  977.         substr s,pos+5,4,msgnum
  978.         if msgnum = selnum         ; correct message?
  979.           found = TRUE             
  980.         endif
  981.       endif
  982.       if not found                 ; no read next
  983.         read s
  984.       endif
  985.     endwhile                       
  986.     if found                       
  987.       i = 0            
  988.       name = "" 
  989.       subject = ""             
  990.       repeat
  991.         read s                     ; display message
  992.         strpos s,"From   :",pos 
  993.         if pos>0                   ; who entered message for reply
  994.           substr s,pos+9,30,name 
  995.         endif
  996.         strpos s,"Subject:",pos    ; get existing subject
  997.         if pos>0
  998.           substr s,pos+9,30,subject
  999.         endif
  1000.         Echo s
  1001.         Echo "^M^J" 
  1002.         more = TRUE
  1003.         i = i+1
  1004.         if i = 22 and more              
  1005.           i = 0
  1006.           Echo " More [y/N] "       ; pause if long message
  1007.           InputChar ch
  1008.           if ch = "^C" or ch = "N"
  1009.             clear com
  1010.             Echo "^M^J"
  1011.             exit
  1012.           endif
  1013.           Echo "^M                    ^M"
  1014.         endif  
  1015.       until s = " End of Message"   ; end of message
  1016.       EchoHilite
  1017.       EchoColor HEADERTEXTCOL
  1018.       Echo "^M^JR)eply ? or [ENTER] to continue "  ; reply to message?
  1019.       InputEcho ch
  1020.       repeat                    
  1021.         if ch = "R"
  1022.           clear com
  1023.           n = total+1              
  1024.           itoa n,nextmsg           ; next message number for reply field
  1025.           tell filepos
  1026.           seek filepos-70          ; start of reply number field
  1027.           read s
  1028.           strpos s, "See Msg:",pos ; check for earlier reply
  1029.           if pos>0                  
  1030.             strpos s,"    ",pos    ; yes locate spaces
  1031.             if pos > 2             ; i.e. after See Msg #
  1032.               length s,len         ; find toal length including spaces
  1033.               strdel s,pos,len-pos+1 ; delete spaces
  1034.               concat s,", "        ; add comma
  1035.               concat s,nextmsg     ; add next reply message number
  1036.               seek filepos-70      ; head of field
  1037.               write s,             
  1038.             endif
  1039.           else                     ; empty string (all spaces)
  1040.             seek filepos-70        ; head of record
  1041.             write "  See Msg: ",n, ; message number of first reply
  1042.           endif
  1043.            reply = TRUE            ; for return to message base
  1044.            addmsg = 0
  1045.            EnterMsg
  1046.            WriteNewRecord name     ; update mail
  1047.         else                       
  1048.           clear com
  1049.           exit
  1050.         endif
  1051.       until ch = "R" or ch = "^M"
  1052.     endif
  1053.   Endproc
  1054.  
  1055.   clear com                        ; main routine
  1056.   clear text
  1057.   EchoClearScreen  
  1058.   reply = FALSE
  1059.   num = 0
  1060.   pos = 0
  1061.   chdir HOSTDIR
  1062.   open MSGBASE 
  1063.   if not success
  1064.     Echo "^M^JSorry no messages available at this time!^M^J"
  1065.     print "SYSOP: Cannot find ",MSGBASE," file"
  1066.     alarm "SYSOP: Cannot find MESSAGE file, disk full ?"
  1067.     return
  1068.   endif            
  1069.   while success 
  1070.     clear text
  1071.     clear com
  1072.     seek 0                         ; go to head of file 
  1073.     read totalmsgs                 ; get total No. of messages
  1074.     atoi totalmsgs,total
  1075.     EchoClearScreen
  1076.     EchoHilite
  1077.     EchoColor HEADERTEXTCOL
  1078.     Echo " Number of Messages : "  ; display number of messages
  1079.     Echo totalmsgs
  1080.     Echo "^M^J S)can   Q)uit   V)iew  or [ENTER] for next msg : "
  1081.     InputEcho ch
  1082.     Echo "^M^J^M^J"        
  1083.     switch ch    
  1084.       case "S":                    ; scan through messages 
  1085.           EchoNormal
  1086.           i = 0 
  1087.           while success
  1088.             read line1             ; start at line 1
  1089.             strpos line1,"Msg#:",pos ; and locate message No. line
  1090.             if pos > 0 
  1091.               read line2
  1092.               read line3 
  1093.               read line4
  1094.               Echo line1           ; show header of message
  1095.               Echo "^M^J"
  1096.               Echo line2 
  1097.               Echo "^M^J"
  1098.               Echo line3
  1099.               Echo "^M^J"
  1100.               Echo line4
  1101.               Echo "^M^J^M^J"
  1102.               i = i + 5
  1103.             endif
  1104.             more = TRUE
  1105.             if i >= 20 and more    ; pause if more messages        
  1106.               i = 0
  1107.               Echo " More [y/N] "
  1108.               InputChar ch
  1109.               if ch = "^C" or ch = "N"
  1110.                 clear com
  1111.                 Echo "^M^J"
  1112.                 exit
  1113.               endif
  1114.               Echo "^M                    ^M"
  1115.             endif  
  1116.           endwhile  
  1117.           Pause 
  1118.       case "Q":                    ; quit message base    
  1119.         close
  1120.         chdir TMDIR  
  1121.         return                       
  1122.       case "^M":                   ; [ENTER] for next message
  1123.         num = num + 1              ; increment to next message
  1124.         if num > total             ; last message? 
  1125.           EchoHilite
  1126.           Echo HEADERTEXTCOL
  1127.           Echo "^M^JThere are no more messages"
  1128.           delay 10
  1129.         else                       ; else show message
  1130.           EchoNormal     
  1131.           found = FALSE 
  1132.           itoa num,selnum          
  1133.           Echo "Msg#: "
  1134.           Echo selnum
  1135.           Echo "^M^J"
  1136.           ShowMsg
  1137.           if reply
  1138.             return
  1139.           endif
  1140.         endif
  1141.       case "V":                    ; view message
  1142.         Echo "^M^JMsg No.? "
  1143.         Inputstring selnum         ; select number of message
  1144.         atoi selnum,num 
  1145.         EchoColor HILITECOL
  1146.         if num > total  or num = 0 ; check validity of selection No.
  1147.           print "^M^JThere are ",totalmsgs," messages only!!!"
  1148.           delay 10
  1149.         else
  1150.           EchoNormal     
  1151.           found = FALSE 
  1152.           Echo "^M^J"
  1153.           seek 6                   ; up to 5 figures (total msgs)
  1154.           ShowMsg                  ; show message
  1155.           if reply
  1156.             return
  1157.           endif
  1158.         endif
  1159.     endswitch
  1160.   endwhile
  1161.   close         
  1162.   chdir TMDIR
  1163. Endproc
  1164.  
  1165.  
  1166. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1167. ;; New Procedure ACCESSMSG
  1168. ;; Allows access to Message Areas, keeps selection 
  1169. ;; Only displays configured message areas.
  1170. ;; Once selected can R)ead, E)nter or Q)uit, ? for help
  1171. ;;                                                     
  1172.  
  1173. Procedure AccessMsg                ; message area listing 
  1174.    string a
  1175.    integer c,n,quit
  1176.    c = 1
  1177.    clear com 
  1178.    clear key
  1179.    clear text
  1180.    EchoClearScreen
  1181.    EchoHilite
  1182.    EchoColor SPECIALTEXTCOL         
  1183.    Echo "^M^J                           ┌───────────────────────┐^M^J"
  1184.    Echo "                           │ Message Area Listings │^M^J" 
  1185.    Echo "                           └───────────────────────┘^M^J"      
  1186.    EchoNormal 
  1187.    while c < COUNT+1               ; only display areas as read
  1188.      switch c                      ; from TMHCFG.HST
  1189.        case 1:   
  1190.          Echo "^M^J                          1.  "
  1191.          Echo area0 
  1192.        case 2:
  1193.          Echo "^M^J                          2.  " 
  1194.          Echo area1 
  1195.        case 3:
  1196.          Echo "^M^J                          3.  "
  1197.          Echo area2 
  1198.        case 4:
  1199.          Echo "^M^J                          4.  "
  1200.          Echo area3
  1201.        case 5:
  1202.          Echo "^M^J                          5.  " 
  1203.          Echo area4   
  1204.        case 6:
  1205.          Echo "^M^J                          6.  "
  1206.          Echo area5 
  1207.        case 7:
  1208.          Echo "^M^J                          7.  "
  1209.          Echo area6
  1210.        case 8:
  1211.          Echo "^M^J                          8.  " 
  1212.          Echo area7
  1213.        case 9:
  1214.          Echo "^M^J                          9.  "
  1215.          Echo area8
  1216.        case 10:
  1217.          Echo "^M^J                          10. "
  1218.          Echo area9 
  1219.      endswitch 
  1220.      c = c+1
  1221.    endwhile
  1222.    n = areanum                     ; save area number 
  1223.    Echo "^M^J^M^JSelect Area Number desired, press [Enter]: "
  1224.    EchoHilite 
  1225.    InputString a 
  1226.    atoi a,areanum
  1227.    if areanum > COUNT
  1228.      Echo "^M^JArea NOT available!!"
  1229.      areanum = n                   ; original areanum
  1230.      delay 10                       
  1231.      return
  1232.    else                            ; once selected
  1233.      switch areanum                ; setup message base and 
  1234.        Case 1:                     ; appropriate file
  1235.          MSGBASE = MSBASE0
  1236.          area = area0
  1237.          areanum = 1               ; command line area number   
  1238.        Case 2:
  1239.          MSGBASE = MSBASE1
  1240.          area = area1
  1241.          areanum = 2                  
  1242.        Case 3: 
  1243.          MSGBASE = MSBASE2
  1244.          area = area2 
  1245.          areanum = 3                  
  1246.        Case 4:
  1247.          MSGBASE = MSBASE3
  1248.          area = area3
  1249.          areanum = 4                  
  1250.        Case 5:
  1251.          MSGBASE = MSBASE4
  1252.          area = area4
  1253.          areanum = 5                  
  1254.        Case 6: 
  1255.          MSGBASE = MSBASE5
  1256.          area = area5 
  1257.          areanum = 6                  
  1258.        Case 7:
  1259.          MSGBASE = MSBASE6
  1260.          area = area6
  1261.          areanum = 7                  
  1262.        Case 8: 
  1263.          MSGBASE = MSBASE7
  1264.          area = area7
  1265.          areanum = 8                  
  1266.        Case 9:
  1267.          MSGBASE = MSBASE8
  1268.          area = area8 
  1269.          areanum = 9                  
  1270.        Case 10:
  1271.          MSGBASE = MSBASE9
  1272.          area = area9
  1273.          areanum = 10                  
  1274.      endswitch   
  1275.      quit = FALSE
  1276.      while not quit
  1277.        EchoClearScreen
  1278.        EchoHilite
  1279.        EchoColor SPECIALTEXTCOL
  1280.        Echo "^M^J^M^JMESSAGE AREA - "
  1281.        Echo area 
  1282.        Echo "^M^JE)nter   R)ead   Q)uit ( ? for commands):" 
  1283.        InputEcho ch
  1284.        switch ch
  1285.          Case "E":                 ; Enter a message
  1286.            name = ""
  1287.            subject = ""
  1288.            addmsg = 0
  1289.            EnterMsg
  1290.            WriteNewRecord name
  1291.          Case "R":                 ; read message  
  1292.            if MSGBASE = MSBASE0    ; message to sysop
  1293.              If userlevel = SYSOPLEVEL  ; read by sysop only
  1294.                ReadMsg
  1295.              else
  1296.                Echo "^M^J^M^JThese are PRIVATE messages!"
  1297.                delay 10 
  1298.              endif
  1299.            else
  1300.              ReadMsg               ; other areas
  1301.            endif                     
  1302.          Case "?":                 ; show available commands
  1303.            EchoNormal
  1304.            Echo "^M^J^M^JE)nter Messages --> S)ave or K)ill"
  1305.            Echo "^M^JR)ead Messages  --> S)can  Q)uit  V)iew  or" 
  1306.            Echo "^M^J                --> [ENTER] for next Message" 
  1307.            Echo "^M^J                --> Msg# and/or R)eply"
  1308.            Echo "^M^JQ)uit           --> Quit message base"
  1309.            Echo "^M^J?               --> This help screen^M^J^M^J"
  1310.            Pause
  1311.          Case "Q":
  1312.            quit = TRUE
  1313.        endswitch        
  1314.      endwhile 
  1315.    endif
  1316. Endproc
  1317.  
  1318. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1319. ;; New Procedure TRASH
  1320. ;; Checks for bad passwords in TRASHCAN.HST
  1321. ;; Sysop edited file - just add passwords not to be accepted
  1322. ;; by system
  1323. ;;
  1324.  
  1325. Procedure Trash                    ; test for bad passwords
  1326.   string s
  1327.   chdir HOSTDIR
  1328.   open "TRASHCAN.HST"              ; trash password file
  1329.   if not success
  1330.     Echo "System error, please call again later^M^J"
  1331.     print "SYSOP: Cannot open TRASHCAN.HST"
  1332.     Disconnect
  1333.     alarm "SYSOP: Cannot open TRASHCAN.HST, disk full ?"
  1334.     return
  1335.   endif
  1336.   while success
  1337.     read s                         ; read word
  1338.     if password = s                ; if password trash, hangup
  1339.       access = FALSE
  1340.     endif  
  1341.   endwhile
  1342.   close 
  1343.   chdir TMDIR
  1344. Endproc
  1345.                                               
  1346. Procedure List                 ; display Filelist
  1347.   string cmd
  1348.   cmd = "type "                           ;"DIR >"
  1349.   clear com
  1350.   clear text
  1351.   concat cmd,DOWNLOADDIR
  1352.   concat cmd,"\files.lst >"
  1353.   concat cmd,FILEDIR                       ; DIR >\HOST.DIR
  1354.   dos "echo One Moment, Loading File List"
  1355.   dos cmd                                  ; shell to DOS
  1356.   TypeFile FILEDIR,TRUE                    ; display \HOST.DIR
  1357.   chdir TMDIR
  1358. Endproc
  1359.                                        
  1360. Procedure Directory                ; display download directory
  1361.   string cmd
  1362.   cmd = "dir "
  1363.   clear com
  1364.   clear text
  1365.   concat cmd,DOWNLOADDIR
  1366.   concat cmd,">"
  1367.   concat cmd,FILEDIR               ; DIR >\HOST.DIR
  1368.   chdir DOWNLOADDIR
  1369.   dos cmd                          ; shell to DOS
  1370.   TypeFile FILEDIR,TRUE            ; display \HOST.DIR
  1371.   chdir TMDIR
  1372. Endproc
  1373.  
  1374. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1375. ;; Addition of Bimodem to Protocol selection.
  1376. ;;
  1377.  
  1378. Procedure Bimod                    ; bimodem transfer
  1379.   clear text
  1380.   clear com 
  1381.   EchoColor GENTEXTCOL
  1382.   Echo "Set-up YOUR end NOW........I am Ready for the transfer.^M^J"
  1383.   Echo "When your end prompts to start my end: press [ENTER]..."
  1384.    InputEcho ""
  1385.    dos "BIMODEM "
  1386.    clear text
  1387.    dos "del Bimodem.Pth"
  1388.    alarm " * Bimodem Transfer(s) Completed * "
  1389.    Echo "^M^J ** Bimodem Transfer Completed ** "
  1390. Endproc
  1391.  
  1392. Procedure FileTransfer string mode,protocol,filename
  1393.   print "^M^JPlease start your transfer procedure or press Ctrl-X to abort^M^J"
  1394.     if mode = "r"
  1395.       if filename=""               ; receive batch files
  1396.         receive protocol
  1397.       else
  1398.         receive protocol,filename  ; receive single file
  1399.       endif
  1400.     else
  1401.       send protocol,filename       ; send multiple files
  1402.     endif       
  1403.     clear com
  1404.     if success
  1405.       Echo "File transfer completed!^M^J"
  1406.     else
  1407.       Echo "File transfer aborted!^M^J"
  1408.     endif
  1409.     Pause
  1410. Endproc
  1411.  
  1412. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1413. ;; New Procedure QUESTIONNAIRE
  1414. ;; Newuser fills out questionnaire, saved to file USER.HST.
  1415. ;; Keep list of users, can be edited if status changes.
  1416. ;;                                                    
  1417.  
  1418. Procedure Questionnaire            ; new users file
  1419.   string address,city,pcode,modemnum,phonenum,datanum,check
  1420.   integer filepos
  1421.   clear com
  1422.   clear text 
  1423.   EchoColor GENTEXTCOL
  1424.   repeat
  1425.   If userlevel < NUSERLEVEL
  1426.     Echo "^M^J You are not found in the user file.^M^J"
  1427.   endif
  1428.   Echo " Would you like to register? [Y/n] : "
  1429.     InputEcho ch
  1430.     if ch = "Y"                          
  1431.       clear com
  1432.       clear text
  1433.       EchoClearScreen
  1434.       EchoHilite
  1435.       EchoColor SPECIALTEXTCOL
  1436.       Echo "^M^J                       ┌────────────────────────────┐^M^J"
  1437.       Echo "                       │ Registration Questionnaire │^M^J" 
  1438.       Echo "                       └────────────────────────────┘^M^J"      
  1439.       chdir HOSTDIR
  1440.       open "USER.HST"              ; user information file
  1441.       if not success
  1442.         create "USER.HST"
  1443.       endif   
  1444.       if not success
  1445.         Echo "System error, please call again later^M^J"
  1446.         print "SYSOP: Cannot create USER.HST"
  1447.         Disconnect
  1448.         alarm "SYSOP: Cannot create USER.HST, disk full ?"
  1449.         return
  1450.       endif
  1451.       seek -1
  1452.       write "**** NEW USER *****"
  1453.       write "NAME:     ",username 
  1454.       tell filepos
  1455.       write "PASSWORD: ",password,"                "
  1456.       write "LEVEL:    ",userlevel
  1457.       repeat
  1458.         Echo "^M^JWhat is your street address ?"
  1459.         Echo "^M^J--->"
  1460.         InputString address
  1461.         Echo address
  1462.         Echo " [y/N] "
  1463.         InputEcho check
  1464.         if check = "N"
  1465.           address = ""
  1466.         endif
  1467.       until check = "Y"
  1468.       write "ADDRESS:  ",address 
  1469.         repeat
  1470.         Echo "^M^J^M^JWhat City are you calling from ? --> "
  1471.         InputString city
  1472.         Echo city
  1473.         Echo " [y/N] "
  1474.         InputEcho check
  1475.         if check = "N"
  1476.           city = ""
  1477.         endif
  1478.       until check = "Y"
  1479.       write "CITY:     ",city
  1480.         repeat
  1481.         Echo "^M^J^M^JWhat is your zip code ? --> "
  1482.         InputString pcode
  1483.         Echo pcode
  1484.         Echo " [y/N] "
  1485.         InputEcho check
  1486.         if check = "N"
  1487.           pcode = ""
  1488.         endif
  1489.       until check = "Y"
  1490.       write "ZIPCODE: ",pcode
  1491.       repeat
  1492.         Echo "^M^J^M^JModem Brand & Speed? --> "
  1493.         InputString modemnum
  1494.         Echo modemnum
  1495.         Echo " [y/N] "
  1496.         InputEcho check
  1497.         if check = "N"
  1498.           modemnum = ""
  1499.         endif
  1500.       until check = "Y" 
  1501.       write "MODEM BRAND & SPEED. ",modemnum
  1502.       repeat
  1503.         Echo "^M^J^M^JVoice phone No. ? --> "
  1504.         InputString phonenum
  1505.         Echo phonenum
  1506.         Echo " [y/N] "
  1507.         InputEcho check
  1508.         if check = "N"
  1509.           phonenum = ""
  1510.         endif
  1511.       until check = "Y"
  1512.       write "PHONE No. ",phonenum
  1513.       repeat
  1514.         Echo "^M^J^M^JData Phone No. or None? --> "
  1515.           InputString datanum
  1516.           Echo datanum
  1517.           Echo " [y/N] "
  1518.           InputEcho check
  1519.           if check = "N"
  1520.             datanum = ""
  1521.           endif
  1522.       until    check = "Y"
  1523.       write "DATA No. ",datanum
  1524.       write "^M^J───────────────────────────────────────────────────────────────────────────────" 
  1525.       repeat
  1526.         Echo "^M^J^M^JPick a password (4 - 16 characters max): "
  1527.         Echo "^M^J--->"
  1528.         InputString password
  1529.         Echo password
  1530.         Echo " [y/N] "
  1531.         InputEcho check
  1532.         if check = "N"
  1533.           password = ""
  1534.         endif
  1535.       until check = "Y" 
  1536.       seek filepos                 ; update password
  1537.       write "PASSWORD: ",password,
  1538.       close
  1539.       chdir TMDIR 
  1540.       clear com
  1541.       clear text
  1542.       Echo "^M^JRegistration information saved " 
  1543.       Save
  1544.       Echo "^M^J^M^JThankyou for filling out the questionnaire.^M^J^M^J"
  1545.       Usage "User filled out Questionnaire......"
  1546.       if userlevel < NUSERLEVEL
  1547.         Echo "If you have provided the correct information, you^M^J"
  1548.         Echo "will be elevated to User STATUS within a day or so.^M^J^M^J^M^J"
  1549.       endif
  1550.       Pause
  1551.     else                                   
  1552.       exit
  1553.     endif
  1554.     Echo "^M^J"
  1555.   until ch = "Y" or ch = "N"       ; repeat until either Y/N   
  1556. Endproc
  1557.  
  1558. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1559. ;; New Procedure WELCOMEUSER
  1560. ;; welcome user after logon, show time, date and No. of personal
  1561. ;; messages.
  1562. ;; choice of reading personal messages at logon
  1563.  
  1564. Procedure WelcomeUser
  1565.   string wname,message 
  1566.   integer len,c,pos
  1567.   c = 1
  1568.   time now
  1569.   strdel now,6,3
  1570.   wname = username
  1571.   length wname,len 
  1572.   strpos wname," ",pos
  1573.   if pos>0                         ; welcome user by
  1574.     strdel wname,pos+1,len-pos     ; first name 
  1575.   endif
  1576.   EchoClearScreen
  1577.   EchoHilite
  1578.   EchoColor SPECIALTEXTCOL
  1579.   Echo "^M^J^M^JHello "
  1580.   EchoColor HILITECOL
  1581.   Echo wname
  1582.   EchoColor SPECIALTEXTCOL
  1583.   Echo "welcome to the "
  1584.   Echo TMHOST
  1585.   print "^M^J^M^JThe time is ",now," on", wdate   ; show time and date
  1586.   put "^M^J^M^JThe time is ",now," on", wdate
  1587.   if msgs = 0                                    ; any mail?
  1588.     Echo "^M^JSorry there is no mail for you today"
  1589.   else 
  1590.     if msgs > 1                    ; yes, show how many
  1591.       message = " messages "
  1592.       print "^M^JYou have ",msgs," personal",message,"to read"
  1593.       put "^M^JYou have ",msgs," personal",message,"to read"
  1594.     else 
  1595.       message = " message "
  1596.       print "^M^JYou have ",msgs," personal",message,"to read"
  1597.       put "^M^JYou have ",msgs," personal",message,"to read"
  1598.     endif
  1599.     Echo "^M^J^M^JRead personal mail [Y/n] "   ; offer choice
  1600.     InputEcho ch                               ; to read mail
  1601.     if ch = "Y"  
  1602.       mail = 0
  1603.       msgread = FALSE 
  1604.       while c < COUNT+1            ; check  all available
  1605.         switch c                   ; message areas
  1606.           case 1:
  1607.             Echo "^M^JMessage area 1 - "
  1608.             Echo area0
  1609.             ReadMail MSBASE0
  1610.           case 2:
  1611.             Echo "^M^JMessage area 2 - "
  1612.             Echo area1
  1613.             ReadMail MSBASE1
  1614.           case 3:
  1615.             Echo "^M^JMessage area 3 - "
  1616.             Echo area2
  1617.             ReadMail MSBASE2
  1618.           case 4:      
  1619.             Echo "^M^JMessage area 4 - "
  1620.             Echo area3
  1621.             ReadMail MSBASE3
  1622.           case 5:
  1623.             Echo "^M^JMessage area 5 - "
  1624.             Echo area4
  1625.             ReadMail MSBASE4
  1626.           case 6:
  1627.             Echo "^M^JMessage area 6 - "
  1628.             Echo area5
  1629.             ReadMail MSBASE5
  1630.           case 7:
  1631.             Echo "^M^JMessage area 7 - "
  1632.             Echo area6
  1633.             ReadMail MSBASE6
  1634.           case 8: 
  1635.             Echo "^M^JMessage area 8 - "
  1636.             Echo area7
  1637.             ReadMail MSBASE7
  1638.           case 9:
  1639.             Echo "^M^JMessage area 9 - "
  1640.             Echo area8
  1641.             ReadMail MSBASE8
  1642.           case 10:
  1643.             Echo "^M^JMessage area 10 - "
  1644.             Echo area9
  1645.             ReadMail MSBASE9
  1646.         endswitch 
  1647.         c = c+1
  1648.       endwhile
  1649.       if msgread
  1650.        Echo "^M^JEnd of personal messages"   
  1651.       endif
  1652.       WriteNewRecord username      ; update record (msgs left)
  1653.     endif                          ; 0 if read all msgs
  1654.   endif
  1655.   Echo "^M^J^M^J"
  1656.   EchoNormal
  1657.   Pause
  1658. Endproc
  1659.  
  1660. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1661. ;; Modified WaitForCall procedure with ANSI variable ANSIREMOTE
  1662. ;; to detect use of Ansi Graphics at logon.
  1663. ;; Beefed up password checking routine, e.g. look for rubbish
  1664. ;; passwords, too may attempts at password.
  1665. ;; Set time on line variable depending on user level.
  1666. ;;
  1667.  
  1668. Procedure WaitForCall              ; wait for connected
  1669.   integer i,len,valid,exist,baudrate
  1670.   set connection,modem
  1671.   LOCAL = FALSE
  1672.   xpert = FALSE
  1673.   while not connected              ; wait for carrier signal
  1674.     inputch ch                     ; sysop commands
  1675.       if success
  1676.         switch ch
  1677.           case "^[":               ; abort
  1678.             HostEnd
  1679.           case "L":                ; local mode
  1680.             set connection,computer  ; this will set connected = 1
  1681.             LOCAL = TRUE
  1682.           case "O":
  1683.             put "~ATH1M0^M~",
  1684.             delay 5
  1685.             set connection,computer  ; this will set connected = 1
  1686.             LOCAL = TRUE
  1687.           case "C":                ; configuration
  1688.             script "TMHCFG"        ; chain to TMHCFG.SCR
  1689.         endswitch
  1690.       endif
  1691.   endwhile
  1692.   if not LOCAL and DETECTBAUD
  1693.     waitfor "CONNECT^M","CONNECT 1200","CONNECT 2400","CONNECT 9600","CONNECT 14400","CONNECT 19200","CONNECT 38400",10
  1694.     if found
  1695.       switch found
  1696.         case 1: baudrate = 1200
  1697.         case 2: baudrate = 2400
  1698.         case 3: baudrate = 9600
  1699.         case 4: baudrate = 14400
  1700.         case 5: baudrate = 19200
  1701.         case 6: baudrate = 38400
  1702.       endswitch
  1703.       set baud,baudrate
  1704.       Echo "Connected at "
  1705.       if not LOCAL
  1706.         put baudrate,"^M^J"
  1707.       endif
  1708.       print baudrate
  1709.     endif
  1710.   endif
  1711.   Echo "^M^J"
  1712.   delay 5
  1713.   clear com
  1714.   clear text
  1715.   delay 5
  1716.   EchoNormal
  1717.   chdir HOSTDIR
  1718.   TypeFile "WELCOME.HST",FALSE     ; display welcome message
  1719.   repeat
  1720.     Echo "Does your Terminal support ANSI Graphics Y/N ?: "
  1721.     InputEcho ch
  1722.     if ch = "Y"
  1723.       ANSIREMOTE = TRUE            ; for ansi display to remote
  1724.     else                           
  1725.       ANSIREMOTE = FALSE
  1726.     endif
  1727.       Echo "^M^J"
  1728.   until ch = "Y" or ch = "N"       ; repeat until either Y/N           
  1729.   chdir TMDIR
  1730.   i = 1
  1731.   len = 0
  1732.   username = ""                    ; enter name (at most 3 times)
  1733.   while i<=3 and len<4 and connected
  1734.     EchoColor GENTEXTCOL
  1735.     Echo "Please enter your First and Last name: "
  1736.     EchoHilite
  1737.     EchoColor HILITECOL
  1738.     InputString username
  1739.     i = i+1
  1740.     length username,len            ; check the length of name
  1741.     if len<4
  1742.       Echo "Name too short, please try again^M^J^M^J"
  1743.     else
  1744.       EchoNormal
  1745.       EchoColor GENTEXTCOL
  1746.       Echo username
  1747.       Echo " [Y/n]? "
  1748.       EchoHilite
  1749.       EchoColor HILITECOL
  1750.       InputString ch
  1751.       if ch="n"
  1752.         len=0
  1753.       endif
  1754.     endif
  1755.   endwhile
  1756.   if len<4 and connected
  1757.     Echo "Goodbye^M^J"
  1758.     Disconnect
  1759.     Usage "User disconnected - name too short"
  1760.   else 
  1761.     i = 1
  1762.     len = 0
  1763.     password = ""                  ; enter password (at most 3 times)
  1764.     while i<=3 and len<4 and connected
  1765.       EchoNormal
  1766.       EchoColor GENTEXTCOL
  1767.       Echo "Password: "
  1768.       EchoHilite
  1769.       EchoColor HILITECOL
  1770.       InputPassword password
  1771.       Trash
  1772.         if not access 
  1773.           Echo "^M^JGarbage Passwords not accepted, access denied!^M^J" 
  1774.           Disconnect
  1775.           Usage "User not accepted - garbage password!"
  1776.           return
  1777.         endif
  1778.       i = i+1
  1779.       length password,len          ; check the length of password
  1780.       if len<4
  1781.         Echo "Password too short, please try again^M^J^M^J"
  1782.       endif 
  1783.     endwhile
  1784.     if len>=4                     ; check password and get user level
  1785.       i = 1
  1786.       while i<=3
  1787.         CheckUser username,password,userlevel,xpert,msgs,valid  
  1788.         if not valid              ; check validity, 3 attempts
  1789.           Echo "Does not match password on file, try again : " 
  1790.           InputPassword password
  1791.         endif 
  1792.         i = i+1
  1793.       endwhile
  1794.     endif
  1795.     if len<4 and connected         ; length wrong, disconnect
  1796.       Echo "Invalid password, access denied^M^J^M^J"
  1797.       Disconnect
  1798.       return  
  1799.       Usage "User disconnected - invalid password"
  1800.     endif
  1801.     if not valid and connected     ; not valid, disconnect
  1802.       Echo "Too many attempts, access denied^M^J^M^J"
  1803.       Disconnect
  1804.       return
  1805.       Usage "User disconnected - Too many attempts at password"
  1806.     else
  1807.       if userlevel = SYSOPLEVEL    ; set logon time
  1808.         ontime = 180
  1809.       elseif userlevel = NUSERLEVEL
  1810.         ontime = 90
  1811.       elseif userlevel < NUSERLEVEL
  1812.         ontime = 20
  1813.         Questionnnaire
  1814.       endif 
  1815.       usage "Logon by:"
  1816.       usage username 
  1817.       time logontime               ; time at user's logon
  1818.       EchoNormal
  1819.       clear com
  1820.       clear text
  1821.       chdir HOSTDIR                ; display notice
  1822.       FileExist "HNOTICE.HST",exist
  1823.       if exist
  1824.         Echo "^M^J"
  1825.         TypeFile "HNOTICE.HST",TRUE
  1826.       endif
  1827.     endif
  1828.   endif 
  1829.   chdir TMDIR
  1830.   WelcomeUser
  1831. Endproc
  1832.  
  1833. Procedure ChatMode                 ; chat mode
  1834.   integer x
  1835.   string rch,lch
  1836.   Echo "^M^JChat mode begin:^M^J"
  1837.   repeat
  1838.     if not LOCAL
  1839.       getch rch
  1840.       if success
  1841.         put rch,
  1842.         if rch = "^M"              ; line feed
  1843.           Echo "^J"
  1844.         endif
  1845.         wherex x
  1846.           if rch = " " and x > 70
  1847.             Echo "^M^J"
  1848.           endif
  1849.       endif
  1850.     endif
  1851.     inputch lch
  1852.     if success and lch<>"^["       ; abort if sysop press [Esc]
  1853.       Echo lch
  1854.       if lch = "^M"
  1855.         Echo "^J"
  1856.       endif
  1857.       wherex x
  1858.       if lch = " " and x > 70
  1859.         Echo "^M^J"
  1860.       endif
  1861.     endif
  1862.   until lch="^[" or not connected
  1863.   Echo "^M^JChat mode end.^M^J^M^J"
  1864.   Pause
  1865. Endproc 
  1866.  
  1867. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1868. ;; New Procedure STATISTICS
  1869. ;; Shows user statistics and enables change of 'Password' or 'Menu Mode'.
  1870. ;;                                
  1871.  
  1872. Procedure Statistics               ; view statistics and 
  1873.   integer len                      ; change password choice
  1874.   clear com
  1875.   clear text 
  1876.   EchoClearScreen
  1877.   EchoColor HILITECOL
  1878.   Echo "^M^J" 
  1879.   Echo username 
  1880.   Echo " - your statistics are:^M^J"
  1881.   EchoColor GENTEXTCOL    
  1882.   Echo "For this call you have "
  1883.   print timeleft,                  ; integers 
  1884.   put timeleft,
  1885.   Echo " minutes remaining.^M^J"
  1886.   Echo "Userlevel: " 
  1887.   if userlevel = 1                 ; show statistics
  1888.     Echo "New User" 
  1889.   elseif userlevel = 2
  1890.     Echo "Normal User"
  1891.   elseif userlevel = 3
  1892.     Echo "Priviledged User"
  1893.   endif
  1894.   Echo "^M^JMenu Mode: "
  1895.   if xpert
  1896.     Echo "Expert (No Menus)"
  1897.   else
  1898.     Echo "Full Menus"
  1899.   endif
  1900.   Echo  "^M^JYour password is: "
  1901.   Echo password 
  1902.   Echo "^M^J^M^J"
  1903.   len = 0
  1904.   EchoNormal
  1905.   EchoHilite        
  1906.   Echo "Change Password ? [y/n] "
  1907.   InputEcho ch
  1908.   if ch = "Y"
  1909.     while len<4  
  1910.       Echo "^M^JNew Password: " 
  1911.       EchoNormal
  1912.       InputPassword password
  1913.       Trash
  1914.       if not access 
  1915.         EchoHilite
  1916.         Echo "^M^JGarbage Passwords not accepted, access denied!^M^J" 
  1917.         Disconnect
  1918.         Usage "User not accepted - garbage password!"
  1919.         return
  1920.       endif
  1921.       length password,len          ; check the length of password
  1922.       if len<4
  1923.         Echo "Password too short, please try again^M^J"
  1924.       else
  1925.         WriteNewRecord username
  1926.         Echo "^M^J^M^JNew Password saved "
  1927.         Save
  1928.         Echo "^M^JWrite it down, it is your new logon password!^M^J^M^J"
  1929.       endif
  1930.     endwhile
  1931.   else
  1932.     EchoNormal
  1933.     Echo "^M^JOriginal Password valid............^M^J^M^J"
  1934.   endif
  1935.   EchoHilite
  1936.   Echo "^M^JIf you have changed your 'Menu Mode' since" 
  1937.   Echo "^M^Jlogging on it can be saved for future logons."
  1938.   Echo "^M^JSave ? [y/n] "
  1939.   EchoNormal
  1940.   InputEcho ch
  1941.   if ch = "Y"
  1942.     WriteNewRecord username        ; update record
  1943.     Echo "^M^JMenu Mode Saved "
  1944.   Save
  1945.   endif 
  1946.   Echo "^M^J^M^J"
  1947.   Pause
  1948. Endproc
  1949.  
  1950. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1951. ;; New Procedure TIMEUP 
  1952. ;; Warns then disconnects user if out of time.
  1953. ;;
  1954.  
  1955. Procedure Timeup                   ; disconnect if over time
  1956.   if timeleft <= 3
  1957.     EchoHilite
  1958.     at 2,20                        ; warning
  1959.     Echo "WARNING - disconnection imminent!"
  1960.     EchoNormal
  1961.   endif
  1962.   if timeleft = 0
  1963.     EchoHilite
  1964.     Echo "^M^JOut of Time.  Connection Terminated^M^J"
  1965.     Disconnect
  1966.     Usage "User disconnected - out of  time"
  1967.   endif  
  1968. Endproc 
  1969.   
  1970. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1971. ;; Modified DoCommand procedure for control of 'Menu mode',
  1972. ;; Ansi menus, calculation of time on, etc.
  1973. ;;
  1974.  
  1975. Procedure DoCommand                ; do a command
  1976.   integer pos
  1977.   clear com
  1978.   clear text
  1979.   time now                         ; current time
  1980.   strdel now,6,3
  1981.   CalcTime logontime,now,mins      ; compare times
  1982.   timeleft = ontime - mins         ; time left online
  1983.   if ANSIREMOTE
  1984.     if xpert                       ; expert mode      
  1985.       Timeup    
  1986.       EchoClearScreen 
  1987.       LocalView
  1988.       EchoColor GENTEXTCOL
  1989.       print "^M^J^M^JCurrent Message Area #",areanum," - ",area
  1990.       put "^M^J^M^JCurrent Message Area #",areanum," - ",area                              
  1991.       print "^M^J",timeleft,XPERTCOMMAND,
  1992.       put "^M^J",timeleft,XPERTCOMMAND,
  1993.     else
  1994.       chdir HOSTDIR
  1995.       TypeFile "MENUANS.HST",FALSE  ; display ansi menu
  1996.       chdir TMDIR
  1997.       Timeup
  1998.       LocalView
  1999.       EchoColor GENTEXTCOL
  2000.       at 0,20
  2001.       print "Current Message Area #",areanum," - ",area
  2002.       put "Current Message Area #",areanum," - ",area                              
  2003.       print timeleft,MENUCOMMAND,
  2004.       put "^M^J",timeleft,MENUCOMMAND,
  2005.     endif
  2006.   else
  2007.     if xpert
  2008.       Timeup
  2009.       LocalView
  2010.       print "^M^J^M^JCurrent Message Area #",areanum," - ",area
  2011.       put "^M^J^M^JCurrent Message Area #",areanum," - ",area                              
  2012.       print "^M^J",timeleft,XPERTCOMMAND,
  2013.       put "^M^J",timeleft,XPERTCOMMAND,
  2014.     else
  2015.       chdir HOSTDIR
  2016.       TypeFile "MENUTXT.HST",FALSE ; display text menu
  2017.       chdir TMDIR
  2018.       Timeup
  2019.       LocalView
  2020.       at 0,20
  2021.       print "Current Message Area #",areanum," - ",area
  2022.       put "Current Message Area #",areanum," - ",area                              
  2023.       print timeleft,MENUCOMMAND,
  2024.       put "^M^J",timeleft,MENUCOMMAND,
  2025.     endif
  2026.   endif
  2027.   if userlevel = SYSOPLEVEL
  2028.     Echo "(H,V) "
  2029.   endif
  2030.   InputEcho ch
  2031.   if ch<>"^M"
  2032.     Echo "^M^J"
  2033.   endif
  2034.   switch ch
  2035.     case "F":                      ; file directory
  2036.       EchoClearScreen
  2037.       chdir DOWNLOADDIR 
  2038.       if FILELIST
  2039.         List
  2040.       else
  2041.         EchoClearScreen
  2042.         chdir DOWNLOADDIR 
  2043.         Directory
  2044.       endif
  2045.     case "T":                      ; type a file
  2046.       clear com
  2047.       EchoClearScreen
  2048.       chdir DOWNLOADDIR
  2049.       Directory
  2050.       EchoColor GENTEXTCOL
  2051.       Echo "^M^JListing of files in host directory...."
  2052.       Echo "^M^JOnly files with extension .TXT should be typed.^M^J^M^J"
  2053.       Echo "Enter filename: " 
  2054.       EchoColor HILITECOL
  2055.       InputFilename filename,DOWNLOADDIR 
  2056.       strpos filename,"TXT",pos 
  2057.       if pos = 0
  2058.         Echo "^M^JFile must have .TXT extension"
  2059.         Delay 20
  2060.       else
  2061.         if success
  2062.           chdir DOWNLOADDIR
  2063.           EchoNormal
  2064.           TypeFile filename,TRUE
  2065.         endif
  2066.       endif
  2067.     case "C":                      ; chat
  2068.       clear com
  2069.       clear text
  2070.       EchoClearScreen
  2071.       Echo "Paging the Sysop, hang on a second!^M^J"
  2072.       alarm "User would like to chat...^JPress [Enter] to accept, [Esc] to deny"
  2073.       if success
  2074.         print "^M^JSYSOP: press [Esc] to terminate chat mode"
  2075.         ChatMode
  2076.       else
  2077.         Echo "^M^JSorry, Sysop is not here^M^J"
  2078.       endif
  2079.     case "U":                      ; upload a file
  2080.       clear com
  2081.       clear text
  2082.       chdir HOSTDIR
  2083.       if ANSIREMOTE 
  2084.         Typefile "PROTOANS.HST",FALSE  ; ansi file
  2085.         EchoColor GENTEXTCOL
  2086.       else
  2087.         TypeFile "PROTOTXT.HST",FALSE
  2088.       endif
  2089.       at 5,20
  2090.       Echo "Select protocol: "   
  2091.       InputEcho protocol
  2092.       Echo "^M^J"
  2093.       if LOCAL
  2094.         Echo "Function not available in local mode^M^J" 
  2095.         delay 10
  2096.       else
  2097.         switch protocol
  2098.           case "I":
  2099.             Bimod
  2100.           case "X","R":
  2101.             Echo "Enter filename: "
  2102.             InputFilename filename,""
  2103.             if success
  2104.               FileTransfer "r",protocol,filename
  2105.             endif
  2106.           case "Z","S","T","M","Y","B","G","H":
  2107.             FileTransfer "r",protocol,""
  2108.         endswitch
  2109.       endif
  2110.     case "D":                      ; download a file 
  2111.       clear com
  2112.       clear text
  2113.       chdir HOSTDIR
  2114.       if ANSIREMOTE 
  2115.         Typefile "PROTOANS.HST",FALSE 
  2116.         EchoColor GENTEXTCOL
  2117.       else
  2118.         TypeFile "PROTOTXT.HST",FALSE
  2119.       endif
  2120.       chdir DOWNLOADDIR  
  2121.       at 5,20
  2122.       Echo "Select protocol: "   
  2123.       InputEcho protocol
  2124.       Echo "^M^J"
  2125.       if LOCAL
  2126.         Echo "Function not available in local mode^M^J"
  2127.         delay 10
  2128.       else
  2129.         switch protocol
  2130.           case "I":
  2131.             Bimod
  2132.           case "X","Y","Z","S","T","M","R","B","G","H":
  2133.             Echo "Enter filename: "
  2134.             InputFilename filename,DOWNLOADDIR
  2135.             if success
  2136.               FileTransfer "s",protocol,filename
  2137.             endif
  2138.         endswitch
  2139.       endif
  2140.     case "X":                      ; toggle expert mode
  2141.       xpert = not xpert
  2142.     case "A":                      ; access, change area and
  2143.       AccessMsg                    ; read or enter message.
  2144.     case "E":                      ; enter message in base already selected 
  2145.       name = ""
  2146.       subject = ""
  2147.       addmsg = 0
  2148.       EnterMsg 
  2149.       WriteNewRecord name
  2150.     case "R":                      ; read messages
  2151.       if MSGBASE = MSBASE0         ; message to sysop
  2152.         If userlevel = SYSOPLEVEL  ; read by sysop only
  2153.           ReadMsg
  2154.         else
  2155.           Echo "^M^J^M^JThese are PRIVATE messages!"
  2156.           delay 10 
  2157.         endif
  2158.       else
  2159.         ReadMsg                    ; other areas
  2160.         WriteNewRecord name
  2161.       endif
  2162.     case "M":                      ; or leave message to Sysop
  2163.       areanum = 1
  2164.       area = area0
  2165.       MSGBASE = MSBASE0
  2166.       subject = ""
  2167.       EnterMsg                     ; leave message
  2168.     case "G":                      ; goodbye
  2169.       chdir HOSTDIR
  2170.       if ANSIREMOTE
  2171.         Typefile "BYEANS.HST",FALSE
  2172.         InputEcho ""
  2173.       else
  2174.         TypeFile "BYETXT.HST",FALSE
  2175.         InputEcho ""
  2176.       endif
  2177.       Disconnect
  2178.       Usage "User logged off"
  2179.       chdir TMDIR
  2180.     case "Q":                      
  2181.       Questionnaire
  2182.     case "B":                      ; show bulletins
  2183.       EchoClearScreen
  2184.       EchoNormal
  2185.       chdir HOSTDIR
  2186.       Typefile "BULLETIN.HST",TRUE
  2187.       chdir TMDIR                         
  2188.       Usage "User read bulletins......"
  2189.     case "Y":                      ; user statistics
  2190.       Statistics
  2191.     case "S":                      ; shell to DOS
  2192.       if userlevel<SYSOPLEVEL
  2193.         Echo "Sorry, this command is for Sysop only^M^J"
  2194.         delay 10
  2195.       else
  2196.         chdir HOSTDIR
  2197.         if LOCAL                   ; local mode shell to DOS
  2198.           Echo "Shelling to DOS ... ^M^J"
  2199.           dos
  2200.           Echo "Return from DOS shell^M^J"
  2201.         else
  2202.           fileexist "hshell.bat",exist   ; check for HSHELL.BAT
  2203.           if exist
  2204.             Echo "Shelling to DOS ... ^M^J"
  2205.             dos "hshell.bat"
  2206.             Echo "Return from DOS shell^M^J"
  2207.           else
  2208.             Echo "SYSOP: Cannot find HSHELL.BAT^M^J"
  2209.           endif
  2210.         endif
  2211.       endif
  2212.     case "V":                      ; view log when remote 
  2213.       if userlevel<SYSOPLEVEL
  2214.         Echo "Sorry, this command is for Sysop only^M^J"
  2215.         delay 10
  2216.       else
  2217.         EchoClearScreen
  2218.         EchoNormal
  2219.         dos
  2220.         chdir TMLOG
  2221.         Typefile "TM.USE",TRUE     ; view log
  2222.         dos
  2223.         chdir TMDIR
  2224.       endif
  2225.     case "?":                      ; show help file of available
  2226.       chdir HOSTDIR                ; commands
  2227.       Typefile "HELP.HST",TRUE
  2228.       chdir TMDIR
  2229.     case "H":                      ; shut down host mode
  2230.       if userlevel<SYSOPLEVEL
  2231.         Echo "Sorry, this command is for Sysop only^M^J"
  2232.         delay 10
  2233.       else
  2234.         Echo "Are you sure [y/N]? "
  2235.         InputString ch
  2236.         if ch="y"
  2237.           Echo "Shutting down host mode^M^J"
  2238.           Disconnect
  2239.           HostEnd
  2240.         endif
  2241.       endif
  2242.     endswitch
  2243. Endproc
  2244.  
  2245. ;
  2246. ; begin main program
  2247. ;
  2248. while FOREVER
  2249.   HostConfig                       ; read configuration file TMHCFG.HST
  2250.   HostBegin                        ; initial mode
  2251.   WaitForCall                      ; wait for a call
  2252.   while connected
  2253.     DoCommand                      ; do commands
  2254.   endwhile
  2255. endwhile
  2256.  
  2257.